Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

348
Visualizações
Electron Amplify AppSync "Realtime disabled when in a server-side environment"

I'm using amplify appsync in my electron app and all works except for the realtime events which means my app doesn't get signalled when the data changes in the cloud.

I know this is because it's running in Node which is what amplify is looking for (JS.browserOrNode) however I don't know how to fix it. Can someone advise me how I can get the realtime updates? When I query it just gets the local data unless I Datastore.stop() and Datastore.start() but surely there's a better way?

Thank you in advance!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Thanks to the amplify team on discord for this one, in amplify-js the logic for the browser vs node check is:

const browserOrNode = () => {
    const isBrowser =
        typeof window !== 'undefined' && typeof window.document !== 'undefined';
    const isNode =
        typeof process !== 'undefined' &&
        process.versions != null &&
        process.versions.node != null;

    return {
        isBrowser,
        isNode,
    };
};

The Datastore logic determines whether it's going to spit that warning or start the subscriptions:

if (isNode) {
    logger.warn(
        'Realtime disabled when in a server-side environment'
    );
} else {
    //#region GraphQL Subscriptions
    [
        // const ctlObservable: Observable<CONTROL_MSG>
        ctlSubsObservable,
        // const dataObservable: Observable<[TransformerMutationType, SchemaModel, Readonly<{
        // id: string;
        // } & Record<string, any>>]>
        dataSubsObservable,
    ] = this.subscriptionsProcessor.start();
}

But because Electron runs the app in a Node.js environment it's why DataStore is disabling realtime.

You can stop this by forcing isNode to be false and then realtime works with electron :)

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda